package com.example.myapplication.activity.advanced_activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.TextView;

import com.example.myapplication.R;

public class EditSimpleActivity extends AppCompatActivity {

    private TextView editText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_simple);
        editText = findViewById(R.id.editText);
        editText.addTextChangedListener(new TextWatcher() {
            // 文本改变前
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                System.out.println("beforeTextChanged");
            }

            // 文本改变时
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                System.out.println("onTextChanged");
            }

            // 文本改变后
            @Override
            public void afterTextChanged(Editable s) {
                String s1 = s.toString();
                System.out.println("afterTextChanged" + s1);
            }
        });
    }
}